import { Column, Entity, JoinColumn, JoinTable, ManyToMany, ManyToOne } from "typeorm";
import { Base } from "libs/Entities/base.entity";
import { Category } from "./category.entity";
import { Tag } from "./tag.entity";

@Entity()
export class Blog extends Base {
    @Column({
        nullable: true,
        type: 'varchar',
    })
    title: string;
    @Column({
        type: 'varchar',
        comment: '封面',
    })
    cover: string;
    @Column({
        comment: '介绍',
    })
    introduce: string;
    @Column({
        comment: '内容',
        nullable: true,
    })
    content: string;
    @Column({
        comment: '内容HTML',
        nullable: true,
    })
    htmlconten: string;
    @Column({
        default:'1',
        nullable: true,
    })
    state: string;
    @ManyToOne(() => Category, (category) => category.blogs,{
        onDelete:"SET NULL"
    })
    @JoinColumn({name: "category_id"})
    category: Category;

    @ManyToMany(()=>Tag)
    @JoinTable()
    Tags: Tag[];

}
